package pdf


import net.sf.ehcache.*
import net.sf.ehcache.store.*
import org.apache.commons.logging.LogFactory
import org.codehaus.groovy.grails.commons.ConfigurationHolder
import org.xhtmlrenderer.pdf.ITextRenderer


class PdfService {

	boolean transactional = false

	byte[] buildPdfFromString(content, baseUri) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
	    ITextRenderer renderer = new ITextRenderer();
	    
	    try {
	    	renderer.setDocumentFromString(content, baseUri);
	    	renderer.layout();
	    	renderer.createPDF(baos);
	    	byte[] b = baos.toByteArray();
	      	
	    	return b
	    } catch (Throwable e) {
	    	log.error e
	    }
  	}

}
